package com.gx.security.base64;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import java.io.IOException;

import static com.gx.security.base64.BouncyCastle.bouncyCastleBase64;
import static com.gx.security.base64.CommonCodes.commonCodeBases;

/**
 * Created by gx on 2017/3/28.
 */
//JDK内置实现
public class Java{

    public static final String src ="imooc security base64";

    public static void jdkBase64(){
        BASE64Encoder encoder = new BASE64Encoder();
        // 加密
        String encode = encoder.encode(src.getBytes());
        System.out.println("encode:"+encode);

        //解密
        BASE64Decoder decoder = new BASE64Decoder();
        try {
            System.out.println("decoder:"+new String(decoder.decodeBuffer(encode)));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        System.out.println("JDK实现~~~~~~~~");
        jdkBase64();
        System.out.println("common实现~~~~~~~~");
        commonCodeBases();
        System.out.println("bc实现~~~~~~~~");
        bouncyCastleBase64();
    }




}
